package com.stream;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo05 {
    public static void main(String[] args) {
        List<String> list = List.of("王思聪","刘晓敏","张三丰","张靓颖","张飞","王敏");
        // 先筛选出所有的“张”姓学员；
        Stream<String> stream1 = list.stream().filter(s -> s.startsWith("张"));
        //l  再筛选出所有的“王”姓学员；
        Stream<String> stream2 = list.stream().filter(s -> s.startsWith("王"));
        //l  将两个流合并为一个流
//        List<String> collect = Stream.concat(stream1, stream2).collect(Collectors.toList());
//        System.out.println(collect);
        Stream.concat(
                list.stream().filter(s -> s.startsWith("张")),
                list.stream().filter(s -> s.startsWith("王"))
        ).forEach(s->{
            System.out.println(s);
        });
    }
}
